package com.zjw.algorithm.ready1;

public class _翻转字符串中的单词 {

    public static void main(String[] args) {
        System.out.println(new _翻转字符串中的单词().reverseWords("the     sky is blue"));
    }

    public String reverseWords(String s) {
        String[] s1 = s.trim().split(" ");
        StringBuilder sb = new StringBuilder();


        for (int i = s1.length - 1; i >= 0; i--) {
            if (s1[i].equals("")){
                continue;
            }
            sb.append(s1[i]);
            if (i > 0) {
                sb.append(" ");
            }
        }

        return sb.toString();
    }
}
